import App from './App'
import uviewPlus, {
	setConfig
} from 'uview-plus' // 引入uview-plus
import {
	createPinia
} from 'pinia'




// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif


// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	const pinia = createPinia()
	uni.getSystemInfo({
		success: function(e) {
			// #ifndef MP 
			// 微信
			app.config.globalProperties.statusBar = e.statusBarHeight // 状态栏高度
			if (e.platform === 'android') {
				app.config.globalProperties.customBar = e.statusBarHeight + 50
			} else {
				app.config.globalProperties.customBar = e.statusBarHeight + 45
			}
			// #endif

			// #ifdef MP-WEIXIN 
			// 微信小程序
			const custom = wx.getMenuButtonBoundingClientRect()
			app.config.globalProperties.statusBar = e.statusBarHeight // 状态栏高度
			if (e.platform === 'ios') {
				app.config.globalProperties.statusBar += 4;
			}
			app.config.globalProperties.customBar = custom.bottom + custom.top - e.statusBarHeight
			// #endif

			// #ifdef MP-ALIPAY
			app.config.globalProperties.statusBar = e.statusBarHeight
			app.config.globalProperties.customBar = e.statusBarHeight + e.titleBarHeight
			// #endif

			// #ifdef APP-PLUS
			app.config.globalProperties.statusBar = e.statusBarHeight
			app.config.globalProperties.customBar = e.statusBarHeight + 45
			// #endif

			// #ifdef H5
			app.config.globalProperties.statusBar = 0
			app.config.globalProperties.customBar = e.statusBarHeight + 45
			// #endif
		}
	})
	app.use(uviewPlus).use(pinia)
	// 需要在app.use(uview-plus)之后执行
	setConfig({
		// 修改$u.config对象的属性
		config: {
			// 修改默认单位为rpx，相当于执行 uni.$u.config.unit = 'rpx'
			unit: 'px'
		},
		// 修改$u.props对象的属性
		props: {
			// 修改radio组件的size参数的默认值， uni.$u.props.radio.size = 30
			radio: {
				// size: 20 
			}
		}
	});
	return {
		app
	}
}
// #endif